icon: Add _set_image
authorTimm Bäder <mail@baedert.org>
Thu, 11 May 2017 05:48:00 +0000 (07:48 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 20 Jul 2017 01:27:12 +0000 (21:27 -0400)
gtk/gtkicon.c
gtk/gtkiconprivate.h

index 691f7ad030e2b03b109b928038941d66f5b0b2b6..7b5327a41ae244bffaea97f27ec66efac30b83ea 100644 (file)
@@ -44,6 +44,7 @@ static void
 gtk_icon_snapshot (GtkWidget   *widget,
                    GtkSnapshot *snapshot)
 {
+  GtkIcon *self = GTK_ICON (widget);
   GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
   GtkAllocation alloc;
 
@@ -52,7 +53,7 @@ gtk_icon_snapshot (GtkWidget   *widget,
   gtk_css_style_snapshot_icon (style,
                                snapshot,
                                alloc.width, alloc.height,
-                               GTK_CSS_IMAGE_BUILTIN_NONE);
+                               self->image);
 }
 
 static void
@@ -68,6 +69,7 @@ static void
 gtk_icon_init (GtkIcon *self)
 {
   gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
+  self->image = GTK_CSS_IMAGE_BUILTIN_NONE;
 }
 
 GtkWidget *
@@ -77,3 +79,10 @@ gtk_icon_new (const char *css_name)
                        "css-name", css_name,
                        NULL);
 }
+
+void
+gtk_icon_set_image (GtkIcon                *self,
+                    GtkCssImageBuiltinType  image)
+{
+  self->image = image;
+}
index 81ae9a2521425a19e4b2b087cb69fc1acdb407b3..dcbb6d7c86d4ec0aa42ea9b16008b4a7722e51df 100644 (file)
@@ -20,7 +20,8 @@
 #ifndef __GTK_ICON_PRIVATE_H__
 #define __GTK_ICON_PRIVATE_H__
 
-#include "gtk/gtkwidget.h"
+#include "gtkwidget.h"
+#include "gtkcsstypesprivate.h"
 
 G_BEGIN_DECLS
 
@@ -37,6 +38,7 @@ typedef struct _GtkIconClass      GtkIconClass;
 struct _GtkIcon
 {
   GtkWidget parent;
+  GtkCssImageBuiltinType image;
 };
 
 struct _GtkIconClass
@@ -48,6 +50,9 @@ GType        gtk_icon_get_type               (void) G_GNUC_CONST;
 
 GtkWidget *  gtk_icon_new                    (const char *css_name);
 
+void         gtk_icon_set_image              (GtkIcon                *self,
+                                              GtkCssImageBuiltinType  image);
+
 G_END_DECLS
 
 #endif /* __GTK_ICON_PRIVATE_H__ */